package com.fengwan.wastesort.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import com.fengwan.wastesort.R
import com.fengwan.wastesort.adapter.WastePageAdapter
import com.fengwan.wastesort.adapter.WasteSortAdapter
import com.fengwan.wastesort.ui.viewModel.WasteDbViewModel
import kotlinx.android.synthetic.main.fragment_waste.*

class WasteFragment : Fragment() {

    companion object {
        fun newInstance() = WasteFragment()
    }

    private val adapter by lazy { WastePageAdapter(childFragmentManager) }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_waste, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        view_pager.adapter = adapter
        tab_layout.setupWithViewPager(view_pager)
        view_pager.offscreenPageLimit = adapter.count
    }

}
